package team.damo.admin.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import team.damo.admin.dao.UserServiceDAO;
import team.damo.admin.mapper.UserMapper;
import team.damo.admin.model.User;

/**
 * @Author: ZhangHeng
 * @Description: TODO
 * @DateTime: 2024/3/12 10:50
 **/
@Component
public class UserServiceDAOImpl implements UserServiceDAO {
    @Autowired
    private UserMapper userMapper;
    @Override
    public boolean isExist(String username) {
        return userMapper.exists(new QueryWrapper<User>().lambda()
                .eq(User::getUsername,username));
    }

    @Override
    public void addUser(User user) {
        userMapper.insert(user);
    }

    @Override
    public User selectByUsername(String username) {
        return userMapper.selectOne(new QueryWrapper<User>().lambda()
                .eq(User::getUsername,username));
    }
}
